Flash Article

Stepping into the New Macromedia Flash MX 2004 Component Structure


Table of Contents

  1. Introduction
  2. Moving Up to v2 Components
  3. Choosing Your Upgrade Path
  4. Upgrading Your Applications
  5. Search and Destroy

Choosing Your Upgrade Path

Although the table above may seem difficult to decode, your deployment options are actually fairly simple. If you're starting a project from scratch in Flash MX 2004, use the new components. However, if you are delivering to Flash Player 6 you'll want to verify that your users have version 6,0,79 or later. It gets a little trickier when you want to upgrade an existing project. In that case, you have three options:

  • Use v1 components and publish to Flash Player 6. There isn't anything new with this option. After all, it's the same as just using Flash MX out of the box. In order to display the old components in the Components panel you can either install the MXP files with the Extension Manager (provided you have the original MXP files) or copy the original FLA files (that contain the components) to the Flash MX 2004 configuration folder. For example, if you working with an English language version of Flash MX 2004, you can take the file Flash UI Components.fla from C:\Program Files\Macromedia\Flash MX\First Run\Components, move it to C:\Program Files\Macromedia\Flash MX 2004\en\First Run\Components, and then restart Flash MX 2004. (Note that en stands for English.)

    Of course, if you use v1 components you won't benefit from any of the cool new features. On the other hand, if you're learning, you will find a wealth of information on using the v1 components, such as books, documentation, articles, and online tutorials.

  • Replace the v1 components with the updated versions in DevNet Resource Kit (DR K) Volume 5 . Many of the original user interface components have been updated so that they work in Flash Player 7 and with ActionScript 2.0. This means that you can use your original code; the components will look the same, and they'll work with any new project you build in Flash MX 2004. However, the components will not reflect the new Halo skin, which may or may not be a disadvantage to your application. Also, there's a nominal cost associated with the DRK. Finally, while all the old syntax works identically, you won't find every v1 component ever created.
  • Replace your v1 components with v2 components. The ultimate upgrade path is to replace all the old components with new ones. This only makes sense when your application has a reasonably long life in front of it. That's because—depending how you structured your application—you may be in for a lot of work. However, the benefits are significant: you'll have access to all the new features, you'll have the new Halo skin, and you can easily extend the class files that drive the new components to make customized versions. The most significant tips in this article fall into this category because it's the most detailed, the most powerful, and the most involved option.

Selecting Your Course of Action

Only you can select the path that makes the most sense for your situation. However, let me mention a few more thoughts for you to consider before I discuss the options in detail.

  • Don't discount one option over the other until you study it fully. For example, only when you are familiar with the advantages of v2 components and know how much work is involved in recoding your application can you really decide whether using v2 components makes sense.
  • Know that each application is different. If you have lots of component instances on several different frames of your application, it's going to be much harder to rework than an application that uses components sparingly or one that follows the good code/data separation methodologies.
  • Be aware that the way you originally populated your components greatly affects how much work is involved to upgrade them. That is, if you had set all the values manually using the Properties panel, upgrading your application will be much more time-intensive than if you had used a script to set the properties..

Here are some global statements that—while only slightly subjective—might help you chart your course:

  • Halo means v2. In order to apply the new Halo theme you must use the v2 components. The only exception is when developing for Macromedia Central.
  • If it ain't broke, don't fix it. That is, if a project you've already delivered is working as is, there's little reason to update it.
  • Migrating to v2 components pays back over time. Only consider an overhaul when your application needs to be around for a while.
  • Learn from your mistakes. If the process of upgrading your application turns out to be unduly painful, take it as an opportunity to analyze your code to see if there was anything you could have done differently to make the transition easier. I'm not saying all well-organized applications will be easy to upgrade, but I do know there are some bad habits (like populating components manually) that make upgrading harder than it has to be.
  • Begin new projects with v2 components. There's almost no reason to avoid the new components when starting a project from scratch. There is a notable file size price to pay, but as you'll see in the following section, the benefits list is huge.
  • Upgrading has a cost, but the benefits are significant. Without suggesting the v2 components are the best option for all cases, I think any long-term project will benefit from an overhaul.

Understanding the Benefits of the v2 Component Architecture

If you're a real Flash geek, then surely you think the v2 components are the greatest thing since ... well, v1 components hit the scene. There's a lot to like. However, when you learn how much work is involved in upgrading your existing applications (see the following section), you might or might not think it's worth the effort. The decision of whether to make the leap to v2 components should be based on how well you appreciate and how much you can exploit the underlying architecture. For example jumping to the new components simply for the Halo look and feel is reasonable, but migrating your applications to the new architecture just because it's something new is difficult to justify.

Here's a quick rundown of what the new features bring to your application.

  • Flash Player 6,0,79 support. This means you can still use the user interface components if you deliver to the last Flash Player 6 version.
  • Improved performance. For example, the DataGrid component runs twice as fast as before.
  • "Export in first frame" issue resolved. Components don't all have to download before the first frame appears.
  • Support for changing the individual styles of components through scripting. The v2 component architecture adds the ability to group several styles together into themes. This way you can change a bunch of styles in one swoop.
  • Support for skinning. For some, however, the fact skinning is done entirely through themes or ActionScript means you can't always dig into a component and swap out a graphic. In fact, many user interface components create their look through the Drawing API—so there's no graphic to swap. Skinning is a double-edged sword—once you set it up it's more powerful, but you may not like how you have to set it up.
  • Styles now include easing! For example, the speed and manner of how the ComboBox component opens and closes can be modified through a script.
  • Data binding support (Flash MX 2004 Professional only). Data binding means you can link dynamic data directly to components. For example, when the user selects a row in the List component you can display related data in a TextArea component. Of course, you can always do this by hand using ActionScript. However, the Component Inspector Panel's Binding tab makes it easy to structure how components and their data get connected. (For an example, read Aral Balkan's article, "Data Binding in Macromedia Flash MX Professional 2004.")
  • Extended components. Because component code resides in open class files, you can change the behavior of a component with just a little bit of ActionScript. For a simple example, later you'll see how to replace the text in a DataGrid cell with a graphic icon.
  • Additional manager classes. This means that controlling focus and layering is entirely automated. The user interface components are also accessible because they follow a logical selection and highlighting behavior when using just your keyboard.
  • Larger file sizes. The file size of just a single component can appear large because it brings with it the underlying v2 architecture. However, if you use all the components you'll see the file size impact is not much greater than if you just use one. For example, a single TextArea component may not be worth the 40K it adds to your file but add the RadioButton, ComboBox, and Numeric Stepper components and you'll only see about another 20K added.
  • New and improved syntax. Because the syntax is new you're in for a bit of learning. However, the improvements are really worth the time investment to learn.

Whether or not these (and other) v2 component features are enough to make you update all your existing applications, the list should surely get you excited about building your next application. In the following section, you'll learn how the new architecture works and how to upgrade your existing applications.